<?php if(!defined('HDPHP_PATH'))exit;C('SHOW_NOTICE',FALSE);?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <title>商品管理</title>
    <script type="text/javascript" src="http://localhost/jumei/Static/js/jquery-1.7.2.min.js"></script>
    <link rel="stylesheet" href="http://localhost/jumei/Static/bootstrap/css/bootstrap.min.css" />
    <link rel="stylesheet" href="http://localhost/jumei/Static/hdjs/hdjs.css" />
</head>
<body>
<div class="wrap">
    <table class="hd-table hd-table-list" style="text-align:center">
        <thead>
        <tr>
            <td width="60">订单id</td>
            <td width="152">订单号</td>
            <td width="100">收货人</td>
            <td>收货地址</td>
            <td width="105">收货人手机号</td>
            <td width="90">订单金额</td>
            <td width="100">下单时间</td>
            <td>备注</td>
            <td>订单状态</td>
            <td width="150">操作</td>
        </tr>
        </thead>
        <tbody>
            <?php foreach ($data as $k=>$v){?>
                <tr>
                    <td class="oid" oid="<?php echo $v['oid'];?>"><?php echo $v['oid'];?></td>
                    <td><?php echo $v['onum'];?></td>
                    <td><?php echo $v['consignee'];?></td>
                    <td><?php echo $v['address'];?></td>
                    <td><?php echo $v['mobile'];?></td>
                    <td><?php echo $v['total'];?></td>
                    <td><?php echo date('Y-m-d H:i',$v['time']);?></td>
                    <td class="oremark"><?php echo $v['remark'];?></td>
                    <td><?php echo $v['state'];?></td>
                    <td>
                            <?php if($v['state']=='待发货'){ ?>
                        <a href="javascript:;" onclick="if(confirm('确定已经发货了吗？')) location.href='<?php echo U('Order/send',array('oid'=>$v['oid']));?>'" class="btn btn-primary btn-sm">发货</a>
                        <?php }else{ ?>
                        <span style="margin-right:10px">已发货</span>
                        <?php } ?>
                        <a href="javascript:;" class="btn btn-danger btn-sm">备注</a>
                    </td>
                </tr>
            <?php }?>
        </tbody>
    </table>
    <form action="javascript:;" method="post" class="remark">
        <input type="text" name="remark" id="" />
        <input type="hidden" name="oid" />
        <span class="close">X</span>
        <input type="submit" value="确定" class="btn" />
    </form>
    <style type="text/css">
    .remark{
        height: 140px;
        width: 270px;
        position: fixed;
        top: 30%;
        right:20%;
        background: rgba(0,0,0,0.9);
        border-radius: 10px;
        display: none;
    }
    .remark .close{
        height: 20px;
        width:20px;
        position: absolute;
        top: 7px;
        right: 7px;
        line-height: 20px;
        text-align: center;
        color: #ffffff;
        opacity: 0.5;
    }
    .remark .close:hover{
        opacity: 0.9;
    }
    .remark input{
        display: block;
    }
    .remark input[name=remark]{
        margin-top: 30px;
        margin-left: 30px;
        border-radius: 5px;
        border: none;
        height: 30px;
        text-indent: 5px;
        font-size: 16px;
    }
    .remark .btn{
        position: absolute;
        bottom: 20px;
        right: 20px;
    }
    </style>
    <script type="text/javascript">
    $(function(){
        $('.close').click(function() {
            $('.remark').fadeOut(200);
        });
        $('.btn-danger').click(function() {
            $('.remark').fadeIn(200);
            var oid = $(this).parents('tr').find('.oid').html();
            $('input[name=oid]').val(oid);
        });
        $('.remark').submit(function() {
            var reData = $(this).serialize();
            var oid = $('input[name=oid]').val();
            var old_remark = $("td[oid="+oid+"]").siblings('.oremark').html();
            var new_remark = $('input[name=remark]').val();
            remark = old_remark +','+ new_remark;
            $.ajax({
                url: "<?php echo U('Order/ajax_remark');?>",
                type: 'post',
                dataType: 'json',
                data: reData,
                success:function(data){
                    $("td[oid="+oid+"]").siblings('.oremark').html(remark);
                }
            })
            $('input[name=remark]').val('');
            $('.remark').fadeOut(200);
            
        });
    })
    </script>
</div>

</body>
</html>


